<template>
	<view class="content">
		<view class="status-text">
			<text>当前工单信息</text>
		</view>
		<u-form class="form-content" :model="info" ref="iForm">
			<u-form-item :border-bottom="false" label-width="30%" label="任务:">
				<text class="form-text">{{info.taskName}}</text>
			</u-form-item>
			<u-form-item :border-bottom="false" label-width="30%" label="客户订单:">
				<text class="form-text">{{info.clientOrderCode}}</text>
			</u-form-item>
			<u-form-item :border-bottom="false" label-width="30%" label="生产工单:">
				<text class="form-text">{{info.workorderCode}}</text>
			</u-form-item>
		</u-form>
		<view class="status-text">
			<text>领料申请记录</text>
		</view>
		<view>
			<uni-list style="margin-left: 2%;" :border="true" v-for="item in issueLineList" :key="item.lineId">
				<uni-list-item style="background-color: #f3f6f9;" :title="item.itemName" :note="convertNote(item)">
				</uni-list-item>
			</uni-list>
		</view>
		<view style="margin-top: 4%;">
			<u-row>
				<u-col>
					<u-button class="btn-gap" type="success" shape="circle" @click="back">返回</u-button>
				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
	import citySelect from '@/components/citySelect/u-city-select.vue';
	import itemSelect from '@/components/itemSelect/itemSelect.vue'
	import {addIssueTask,getIssueDetail} from '@/api/work/issue/issue.js'
	export default {
		components: {
			citySelect,
			itemSelect
		},
		data() {
			return {
				info: {
					workorderCode: null,
					clientOrderCode: null,
					taskName: null
				},
				issueLineList: [],
				query:{}
			};
		},
		onLoad(options) {
			let eventChannel = this.getOpenerEventChannel();
			let that = this;
			eventChannel.on('acceptDataFromOpenerPage', function(data) {
				that.info.taskName = data.taskName;
				that.info.workorderCode = data.workorderCode;
				that.info.clientOrderCode = data.clientOrderCode;
			});
			this.getIssueDetail(that.info.workorderCode);
		},
		methods: {
			/**
			 * 查询详情
			 */
			getIssueDetail(workorderCode){
				this.query.workorderCode = workorderCode;
				getIssueDetail(this.query).then(res => {
					this.issueLineList = res.data;
				});
			},
			convertNote(item){
				return `领料数量: ${item.quantityIssued} , 单位: ${item.unitOfMeasure} , 领料日期: ${this.$isEmpty(item.issueDate)?'':item.issueDate}`
			},
			/** 
			 * 返回
			 */
			back() {
				uni.navigateBack({
					delta: 1
				})
			}
		}
	};
</script>

<style lang="scss">
	/deep/ .uni-list-item__content-title {
		font-size: 18px;
	}
	
	/deep/ .uni-list-item__content-note {
		font-size: 16px;
	}
	
	/deep/ .uni-list-item__extra-text {
		font-size: 16px;
		color: #7da6ec;
	}
	
	.form-content {
		border-radius: 15px;
		background-color: white;

		.u-form-item {
			margin-left: 3%;
			font-size: 18px;
		}

		.form-text {
			color: #999999;
			text-align: right;
			margin-left: 20%;
		}
	}
</style>